<#macro search >
<form class=" navbar-left col-md-7 col-md-offset-1"  id="searchForm" action="/topic/search" method="get">
  <#--  <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>-->
    <div class="form-group col-md-12" style="position: relative;margin-bottom: 0;">
        <input type="text" class="form-control" name="q" id="q" value="${q!}" autocomplete="off" onkeydown="if(event.keyCode==13){searchForm();return false};"  placeholder="回车搜索">
        <button type="button" class="search-btn glyphicon glyphicon-search" onclick="searchForm();"></button>
    </div>
</form>
<#--<div class="lsss">历史搜索:</div>
<div class="sslb" id="lssslb">
</div>-->


<#--<script src="//cdn.bootcss.com/layer/2.4/layer.min.js"></script>-->
<script src="/static/layer/layer.js"></script>
<script type="text/javascript">

    function searchForm(){
        var parm = $("#q").val();

        if(parm==""){
            layer.alert("请输入留言题目查询");
            return false;

        }
        /*setHistoryItems(parm);*/
        document.getElementById("searchForm").submit();
    }


    /*$(function(){
        var str=localStorage.historyItems;
        var s = '';
        alert(str);
        if(str==undefined){
            s='<div class="rmssts">暂无搜索记录...</div>';
            $("#lssslb").append(s);
        }else{
            var strs= new Array();
            strs=str.split("|");
            for(var i=0;i<strs.length;i++){
                s+= "<a href='/topic/search?q="+strs[i]+"' >"+strs[i]+"</a>";
            }
            $("#lssslb").append(s+'<input type="button" class="scls" onclick="clearHistory();" value="清除历史记录">');
        }
    });*/

    /*<span style="white-space:pre"> </span>*/

            //存值方法,新的值添加在首位
    /*function setHistoryItems(keyword) {
        keyword = keyword.trim();
        let {historyItems}  = localStorage;
        if (historyItems === undefined) {
            localStorage.historyItems = keyword;
            alert(localStorage);
        } else {
            const onlyItem = historyItems.split('|').filter(e => e != keyword);
            if (onlyItem.length > 0) historyItems = keyword + '|' + onlyItem.join('|');
            localStorage.historyItems = historyItems;
        }
        alert(historyItems);
    }

    //清除值
    function clearHistory() {
        localStorage.removeItem('historyItems');
        var div = document.getElementById("lssslb");
        while(div.hasChildNodes()) //当div下还存在子节点时 循环继续
        {
            div.removeChild(div.firstChild);
        }
        $("#lssslb").append('<div class="rmssts">暂无搜索记录...</div>');
    }*/
</script>

</#macro>